The image data stored in the array of bytes. This object must be initialized with the proper image data and it must be disposed of by the user as well.
Example





In This Topic
GdPicture14 Namespace / GdPictureImaging Class / CreateGdPictureImageFromByteArray Method / CreateGdPictureImageFromByteArray(Byte[]) Method

CreateGdPictureImageFromByteArray(Byte[]) Method

In This Topic
Creates a new GdPicture image from an image file stored as an array of bytes. The newly created image is identified by its unique non-zero image identifier.

Please note that it is your responsibility to release the image resources once you have no use for them.

Syntax
'Declaration
 
Public Overloads Function CreateGdPictureImageFromByteArray( _
   ByVal Data() As Byte _
) As Integer
public int CreateGdPictureImageFromByteArray( 
   byte[] Data
)
public function CreateGdPictureImageFromByteArray( 
    Data: Bytearray of
): Integer; 
public function CreateGdPictureImageFromByteArray( 
   Data : byte[]
) : int;
public: int CreateGdPictureImageFromByteArray( 
   byte[]* Data
) 
public:
int CreateGdPictureImageFromByteArray( 
   array<byte>^ Data
) 

Parameters

Data
The image data stored in the array of bytes. This object must be initialized with the proper image data and it must be disposed of by the user as well.

Return Value

A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created. Please first of all use the GetStat method to determine if this method has been successful.

Be aware that you need to release the image with the ReleaseGdPictureImage method after being used.

Remarks
It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

All document formats currently supported by the toolkit are listed here.

This class loads multipage images (GIF and TIFF formats) in read-write mode by default. If you want to open multipage images in read-only mode, you need to call the GifOpenMultiFrameForWrite method for GIF format and the TiffOpenMultiPageForWrite method for TIFF format and set the WriteAccess parameter to false before creating an image.

This method requires the Image Documents component to run.

Example
Creating a GdPicture image from an image file stored as an array of bytes and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Stream stream = File.Open("image.jpg", FileMode.Open))
{
    // Load the file to an array of bytes for the sake of demonstration.
    // In a production context, the image file should be obviously loaded with CreateGdPictureImageFromFile.
    int size = (int)stream.Seek(0, SeekOrigin.End);
    byte[] buffer = new byte[size];
    stream.Seek(0, SeekOrigin.Begin);
    stream.Read(buffer, 0, size);
 
    // Create the GdPicture image and save it as a PNG.
    int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(buffer);
    gdpictureImaging.SaveAsPNG(imageID, "image.png");
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also